<?php include "verifica.php"; ?>
<html>
<head>
	<title>ABR</title>
</head>
<body>
	<div class="box">

		<?php
			include "topo.php";
			include "menu.php";
		?>		
			<div class="formulario">
				<?php 	
					include "conexao.php";

					$id = $_GET['id'];
					$sql_select = mysql_query("SELECT * FROM tb_usuario WHERE id = '$id' ");
					while($linha = mysql_fetch_array($sql_select)){
						$nome = $linha['nome'];
						$email = $linha['email'];
						$senha = $linha['senha'];
					}
				?>
				<fieldset>
					<legend>Edição de Usuário</legend>
					<form name="form1" action="crud_usuario.php?funcao=update&id=<?php echo $id ?>" method="POST">
						<h4>* Primeiro escolha clicando no editar do usuário e depois edite os dados.</h4>
						<table>
                            <tr>
                                <td>Nome:</td>
                                <td><input type="text" name="nome" value="<?php echo $nome ?>"></td>
                            </tr>
                            <tr>
                                <td>Email:</td>
                                <td><input name="email" type="text" value="<?php echo $email ?>"></td>
                            </tr>
                            
                            <tr>
                                <td>Senha:</td>
                                <td><input name="senha" type="password" value="<?php echo $senha ?>" ></td>
                            </tr>
                            <tr>
                            	<td></td>
                                <td>
			                        <input type="submit"  onclick="return validarUsuario()" value="Alterar">
                                </td>
                            </tr>
						</table>
					</form>

				<fieldset>
					<legend>Relação de Usuários</legend>
						<table>
							<tr>
								<th>Nome</th>
								<th>Email</th>
								<th>Código</th>
								<th>Editar</th>
							</tr>
							<?php 
								$sql_select = mysql_query("SELECT * FROM tb_usuario ORDER BY nome");
								while($linha = mysql_fetch_array($sql_select)){ 
								$pega_id = $linha['id'];
								$pega_nome = $linha['nome'];
								$pega_email = $linha['email'];
								$pega_senha = $linha['senha'];

							?>
							<tr>
								<td><?php echo $pega_nome ?></td>
								<td align="center"><?php echo $pega_email ?></td>
								<td align="center"><?php echo $pega_id ?></td>
                                <td align="center"><a href="formulario_editar_usuario.php?funcao=edit&id=<?php echo $pega_id ?>"><img src="images/edit.png"></a></td>
                            </tr>
                       

							<?php } ?>

						</table>	
				</fieldset>
			</div><!--formulario-->

		<?php	
			include "rodape.php";
		?>

	</div><!--box-->
</body>
</html>